package com.woniuxy.oa.dao;

import com.woniuxy.oa.entity.Permission;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @description:
 * @author: guohao
 * @time: 2019/12/25 11:00
 */
public interface PermissionDAO {
    /**
     * 查询所有权限
     * @return
     */
    @Select("select * from oa_permission")
    public List<Permission> getPermissions();
    /**
     * 根据用户的角色获得其权限
     * @param empId
     * @return
     */
    @Select("select p.* from oa_role_emp re,oa_role_perm rp,oa_permission p where re.`roleid`=rp.`roleid` and rp" +
            ".`permid`=p.`id` and re.`empId`=#{empId}")
    public List<Permission> getPermisstionByRoleOfUser(String empId);
    /**
     * 根据用户ID获得其权限
     * @param empId
     * @return
     */
    @Select("select p.*,e.* from oa_permission p,oa_emp_perm em,oa_emp e where p.`id`=em.`permid` and e.`id`=em" +
            ".`empId` and e.id=#{empId}")
    public List<Permission> getPermisstionByUser(String empId);



    /**
     * @Description //根据部门id查询部门的权限
     * @Date 2019/12/30 15:00
     * @param deptId
     *@return java.util.List<com.woniuxy.oa.entity.Permission>
     **/
    @Select("SELECT * FROM oa_dept d,oa_permission p,oa_dept_perm dp WHERE d.id=dp.deptid AND p.id=dp.permid and d.id=#{id}")
    public List<Permission> getPermissionById(int deptId);
}

